<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>all接收成功和失败的</title>
</head>
<body>
<script>
    const p1 = Promise.resolve('success');
    const p2 = Promise.reject('fail');
    const p3 = new Promise(((resolve, reject) => {
        setTimeout(() => {
            reject('timeout fail')
        }, 2000)
    }));

    const pAll = Promise.all([p1, p2, p3].map(p => p.catch(reason => Promise.resolve(reason))));
    pAll.then(values => {
        console.log(values);
    })
</script>
</body>
</html>
